<?php 
/**
 * eBay Label Printing Program Printer Profile Database Table Class 
 * this is a Db Table Class , It stores Printer Profile information
 * @package  eBayLabelPrinter
 * @category Models/DbTable
 * @author   Norman Dong <norman.dong@hotmail.com>
 * @version  Initial
 * @copyright LeadCasket.com
 * @link     www.leadcasket.com
 * @license  Commercial
 */
 class Model_DbTable_Customers_Printerprofile extends Zend_Db_Table_Abstract 
{
	/**
	 * @var string Class Table Name
	 */
	protected $_name = 'customer_printer_profile';	
	
	/**
	 * Get Printer Profile Function
	 * Get single Row of Printer Profile
	 * @param int $idPrinterProfile
	 * @return array  
	 */
	public function getPrinterProfile($idPrinterProfile){
		$row = $this->fetchRow('`id_printer_profile`='.(int)$idPrinterProfile);
		if(!$row){
			return false;
		}
		return $row->toArray();		
	}
	
	/**
	 * Add a Printer Profile into the Database
	 * User select Printer / Model from  the Manufacture Database 
	 * @param int $idSeller
	 * @return array  Not decide what to return
	 */
	
	public function addPrinterProfile($printerManuID,$printerModelID,$offsetTop,$offsetRight,$offsetBottom,$offsetLeft,$offsetUnitID){
		
		$data = array(
				'offset_printer_top' => $offsetTop,
				'offset_printer_bottom' => $offsetBottom,
				'offset_printer_left' => $offsetLeft,
				'offset_printer_right' => $offsetRight,
				'offset_printer_id_unit' => $offsetUnitID,
				'id_printer_manufacture' => $printerManuID,
				'id_printer_model' => $printerModelID				 
				);
		$this->insert($data);
	}
	
	/**
	 * Check if Unique Printer Profile
	 * if new Configure Not exist Add it 
	 * if new Configure Or modified Configure Exist then Simply return the 
	 * Configure ID back to Customer Profile to change it
	 * @param int $idSeller  The Seller ID
	 * @return array  Not decide what to return
	 */
	
	public function checkUniquePrinterProfile($printerManuID,$printerModelID,$offsetTop,$offsetRight,$offsetBottom,$offsetLeft,$offsetUnitID){

		$select = $this->_db ->select()
		-> from ($this->_name,array('id_printer_profile'))
		-> where('`offset_printer_top` = ?',$offsetTop)
		-> where('`offset_printer_bottom` = ?',$offsetBottom)
		-> where('`offset_printer_left` = ?',$offsetLeft)
		-> where('`offset_printer_right` = ?',$offsetRight)
		-> where('`offset_printer_id_unit` = ?',$offsetUnitID)
		-> where('`id_printer_manufacture` = ?',$printerManuID)
		-> where('`id_printer_model` = ?',$printerModelID)
		-> limit(5);
		$result = $this->getAdapter()->fetchAll($select);
		
		if(!$result){
			return false;
		}
		
		return $result->toArray();
	}
	
	/**
	 * Get Seller Group By ID
	 * Not decide what to do Yet
	 * @param int $idSeller  The Seller ID
	 * @return array  Not decide what to return
	 */
	
	public function deletePrinterProfile($idPrinterProfile){
		$this->delete('id_printer_profile =' . $idPrinterProfile);
	}

	/**
	 * Search Printer Profile According 
	 * Manufacture and Printer model
	 * @param int $idPrinterManu
	 * @param int $idPrinterModel
	 * @return array
	 */
	
	public function searchPrinterProfile($idPrinterManu,$idPrinterModel){
		
	}
}
?>